<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cn.ac.cintcm.dataconverge.dataAnalyze.form.*,cn.ac.cintcm.dataconverge.researcher.domain.*,
java.util.*,com.hs.core.page.PageUtil,com.hs.core.utils.StringUtilTool,cn.ac.cintcm.dataconverge.util.Constants" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List tagList = (List)request.getAttribute("tagList");
int tagSize = tagList.size();
List orgList = (List)request.getAttribute("orgList");
int orgSize = orgList.size();
Map dataMap = (Map)request.getAttribute("dataMap");
int allNum = 0;
Double allFund = 0d;
List allOrg = (List)request.getAttribute("allOrg");
List tags = (List)request.getAttribute("tags");

String subjectYear = (String)request.getAttribute("subjectYear");
String orgid = (String)request.getAttribute("orgid");
String orgRole = (String)request.getAttribute("orgRole");
String state = (String)request.getAttribute("state");
String subjectTag = (String)request.getAttribute("subjectTag");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:tvns>
<head>
   <link href="<%=basePath%>index/Themes/com/style.css" rel="stylesheet" type="text/css" />
    <script src="<%=basePath%>index/Scripts/Script.js" language="javascript" type="text/javascript"></script>
     <script src="<%=basePath%>js/common.js" language="javascript" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
function statSubject(){ 
  var content = document.getElementsByName("subjectTag");
  var flag = false;
  for(var i=0;i<content.length;i++){
  	if(content[i].checked){
  		flag = true;
  		break;
  	}
  	  
  }
  if(!flag)
     alert("请选择一项统计内容进行统计");
     else
  searchform.submit(); 
}


</script>
</head>
<body scroll="yes">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td>
               <form name="searchform" action = "<%=path%>/subjectAnalyze.htm?action=statByContent" method="post">
    <div class="r_rtm_tb_mg1">
        <div class="r_rtm_tb1">
            <span>
                <img src="<%=path%>/index/Themes/com/idt_tb_pass.gif" />&nbsp;&nbsp;课题内容统计</span>
        </div>
    </div>  
     <table cellspacing="2" cellpadding="0" width="100%" class="idt_item_mg" id="Table2">
        <tr>
            <td class="fim_l" width="10%">
                统计内容：</td>
            <td class="fim_r"  width="40%">
                <%
                  for(int k = 0;k<tags.size();k++){
                	  Map tag = (Map)tags.get(k);
                	  out.print("<input type=radio name=subjectTag value=\"");
                	  out.print(tag.get("ID")+"\"");
                	  if((tag.get("ID")+"").equals(subjectTag))
                		  out.print(" checked");
                	  out.print("/>&nbsp;");
                	  out.print(tag.get("NAME"));
                	  out.print("&nbsp;");
                  }
                %>
                </td>
            <td class="fim_l" width="10%">
               单位</td>
            <td class="fim_r" nowrap  colspan="2">
                <select name="orgId">
                  <option value="0">-----请选择统计单位-----</option>
                  <%if(allOrg != null && allOrg.size()>0){
                	   for(int m = 0;m<allOrg.size();m++){
                		   Organization org = (Organization)allOrg.get(m);
                		   out.print("<option value=" + org.getId());
                		   if((org.getId()+"").equals(orgid))
                			   out.print( " selected");
                		   out.print(">");
                		   out.print(org.getName());
                		   out.print("</option>");
                	   }
                	  
                  }  %> 
                </select> &nbsp;
                <select name="orgRole">
		    		<option value="0">---请选择单位角色---</option>
		      		<option value="<%=Constants.org_role_leader %>" <%if(Constants.org_role_leader.equals(orgRole)){out.print(" selected");} %>>牵头单位</option>
		      		<option value="<%=Constants.org_role_participant %>" <%if(Constants.org_role_participant.equals(orgRole)){out.print(" selected");} %>>参与单位</option>
		    	</select>
            </td> 
        </tr>
        <tr>
            <td class="fim_l">
                课题状态：</td>
            <td class="fim_r">
                <select name="state" >
		  			<option value="-1" >---请选择课题状态---</option>
					<option value="0" <%if("0".equals(state)){out.print(" selected");} %>>申报中</option>
					<option value="5" <%if("5".equals(state)){out.print(" selected");} %>>未中标</option>
					<option value="1" <%if("1".equals(state)){out.print(" selected");} %>>中标</option>
					<option value="2" <%if("2".equals(state)){out.print(" selected");} %>>在研</option>
					<option value="3" <%if("3".equals(state)){out.print(" selected");} %>>申请结题</option>
					<option value="4" <%if("4".equals(state)){out.print(" selected");} %>>已结题</option>	
				</select>
            </td>
            <td class="fim_l">
                所属年份</td>
            <td class="fim_r" nowrap width="30%"> 
            	<input type="text" class="Wdate" id="subjectYear" value="<%=subjectYear==null?"":subjectYear %>" style="width:40%" name="subjectYear"  onFocus="WdatePicker({el:'subjectYear',dateFmt:'yyyy'})" />
            </td> 
            <td class="fim_r" align="center"  >
                <input type="button" value="统计"  onclick="statSubject()" class="com_btn2" id="Button5">
            </td>
        </tr>
        
    </table> 
            </td>
        </tr>
        </form>
        <tr>
            <td>
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td class="main_content_l2">
                            &nbsp;
                        </td>
                        <td>
                            <table border="0" cellpadding="1" cellspacing="2" width="100%">
                                <tr style="background-color: #ACDBEB; height: 30px;">
                                    <th>
                                        序号
                                    </th>
                                    <th>
                                        单位名称
                                    </th>
                                    <%
                                    for(int i = 0;i<tagSize;i++){
                                       Map tag = (Map)tagList.get(i); 
                                       out.print("<th>"+tag.get("NAME")+"</th>"); 
                                    } 
                                     %>
                                    <th>
                                            <font color=red>课题总数</font>
                                    </th>
                                    <th>
                                           <font color=red> 中标经费</font>
                                    </th>
                                </tr>
                                <% 
                                   int  index = 0;
                                   for(int k=0;k<orgSize;k++){
                                        index++;
                                   		Map org = (Map)orgList.get(k);  
                                   		String orgId = org.get("ID") + "";
                                   		int  flag = index/2;
                                 %>
                                <tr style="height: 23px; background-color: #fff;">
                                    <td align="center">
                                        <%=index %>
                                    </td>
                                    <td align="center">
                                        <%=org.get("NAME") %>
                                    </td>
                                     <% for(int i = 0;i<tagSize;i++){
                                      		 Map tag = (Map)tagList.get(i); 
                                      		 String tagId = tag.get("ID") + "";
                                      		 out.print("<td align=\"center\">");
                                      		 StatObj obj = (StatObj)dataMap.get(orgId + "#" + tagId);
                                      		 out.print(obj.getAllCount());
                                      		 out.print("</td>"); 
                                      		 allNum+=obj.getAllCount();
                                     }%>
                                     <td align="center">
                                        <%=org.get("COUNTNUM") %>
                                    </td>
                                    <td align="center">
                                        <%=org.get("SUMFUND") %>
                                    </td>
                                </tr> 
                                <tr style="height: 23px; background-color: #fff;">
                                    <td align="center">
                                       
                                    </td>
                                    <td align="center">
                                             <font color=red>课题总数</font>
                                    </td> 
                                     <%
	                                    for(int i = 0;i<tagSize;i++){
	                                       Map tag = (Map)tagList.get(i); 
	                                       out.print("<td align=\"center\"><font color=red >");
	                                       out.print(tag.get("COUNT")==null?"0":tag.get("COUNT"));
	                                       out.print("</font></td>");
	                                       
	                                    } 
                                     %>
                                    <td align="center">
                                       
                                    </td>
                                    <td align="center">
                                             
                                    </td> 
                                </tr> 
                                 <tr style="height: 23px; background-color: #fff;">
                                    <td align="center">
                                       
                                    </td>
                                    <td align="center">
                                             <font color=red>中标经费</font>
                                    </td> 
                                     <%
	                                    for(int i = 0;i<tagSize;i++){
	                                       Map tag = (Map)tagList.get(i); 
	                                       out.print("<td align=\"center\"><font color=red >");
	                                       out.print(tag.get("ALLFUND")==null?"0":tag.get("ALLFUND"));
	                                       out.print("</font></td>"); 
	                                    } 
                                     %>
                                    <td align="center">
                                       
                                    </td>
                                    <td align="center">
                                             
                                    </td> 
                                </tr> 
                                 <%} %>
                                <tr style="height: 23px; background-color: #ffffff;">
                                    <td colspan="<%=tagSize+4%>">
                                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                            <tr style="font-weight: bold;">
                                                <td>
                                                    合计：
                                                </td>
                                                <td>
                                                    课题总数：<%=allNum %>
                                                </td>
                                                <td>
                                                    经费：60
                                                </td> 
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td class="main_content_r2">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td class="main_bottom_l2">
                        </td>
                        <td class="main_bottom_m2">
                            &nbsp;
                        </td>
                        <td class="main_bottom_r2">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
